package cn.summit.log.config;

import cn.summit.log.AccessLogAspect;
import cn.summit.log.service.AccessLogService;
import cn.summit.log.service.impl.DefaultAccessLogServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @author summit
 * @since 2020/6/23 17:27
 */
@Configuration
@EnableAspectJAutoProxy
public class AccessLogConfig {

    @Bean
    @ConditionalOnMissingBean(AccessLogService.class)
    public AccessLogService defaultAccessLogService() {
        return new DefaultAccessLogServiceImpl();
    }

    @Bean
    public AccessLogAspect accessLogAspect(AccessLogService accessLogService) {
        return new AccessLogAspect(accessLogService);
    }
}
